package cn.com.nes.site.service.system.wechatProgram.impl;

import cn.com.nes.mybatis.agent.system.entity.WechatProgramConfig;
import cn.com.nes.mybatis.agent.system.mapper.WechatProgramConfigMapper;
import cn.com.nes.site.service.system.wechatProgram.WechatProgramConfigService;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WechatProgramConfigServiceImpl extends ServiceImpl<WechatProgramConfigMapper, WechatProgramConfig> implements WechatProgramConfigService {


    @Override
    public WechatProgramConfig queryWechatProgramConfigByProgramCode(String programCode) {
        if (StrUtil.isBlank(programCode)) {
            programCode = StrUtil.EMPTY;
        }

        QueryWrapper<WechatProgramConfig> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("program_code", programCode);
        queryWrapper.eq("deleted", false);
        List<WechatProgramConfig> wechatProgramConfigs = this.baseMapper.selectList(queryWrapper);

        return wechatProgramConfigs.get(0);
    }
}
